<script>
	var mpscheme =
		'meipian://main.app.new/meipian?path=meipian%253A%252F%252Farticle%252Fdetail%253Fmask_id%253D3h5c9hhy%2526cb_create_at%253D1618909940%2526cb_expire_time%253D1800%2526client_type%253D2%2526type%253Dwechat%2526source%253Dh5wx_article_top&_sdk_=umeng&um_tc=f46a890aa43c404b95565ea58e9c3e2d&_valid_user_id_=4-c2afd3a446004288a60db5e802ec6c71&_linkid_=usr10s8s5q7tfvhb&source=h5wx_article_top&_bizType_=ushare';
	var oid = '';
	if (localStorage && localStorage.setItem && localStorage.getItem) {
		oid =
			localStorage.getItem('_umeng_oid') ||
			(+new Date()).toString(36) + Math.random().toString(36).substr(2, 6);
		localStorage.setItem('_umeng_oid', oid);
	}
	document.getElementById('oid').innerText = 'umtestid_' + oid;
	var data = ULink.getUriDecodeParams();
	var tm = parseInt(data.timeout);
	var lazy = data.lazy === 'true' ? true : false;
	if (Object.is(tm, NaN)) {
		tm = undefined;
	}
	var auto = data.auto === 'true' ? true : false;
	var tip = data.tip;
	var tipitem;
	var clp;
	if (data.clp === 'true') {
		clp = true;
	} else if (data.clp === 'false') {
		clp = false;
	} else if (data.clp === 'function') {
		clp = function (clptoken) {
			return mpscheme + '&umclp=' + clptoken;
		};
	}
	function proxyOpenDownloadfn (defaultAction, cctx) {
		if (data.popup === 'true') {
			defaultAction();
		} else {
			if (cctx.solution.type === 'scheme') {
				if (ULink.isWechat || ULink.isQQ) {
					defaultAction();
				} else {
					location.href = cctx.solution.downloadUrl;
				}
			}
		}
	}
	if (tip === 'default') {
		tipitem = tip;
	} else if (tip === 'function') {
		tipitem = function (ctx) {
			return `<div style="position:fixed;left:0;top:0;background:rgba(255,0,255,0.5);width:100%;height:100%;z-index:19910324;">${ctx.solution.downloadUrl}</div>`;
		};
	}
	if (data.env === 'pre') {
		ULink.setGateway('https://pre-c.umsns.com');
	}
	if (ULink.isWechat) {
		var btn = document.getElementById('launch-btn');
		btn.style.display = 'block';
		btn.addEventListener('launch', function (e) {
			console.log('success');
		});
		btn.addEventListener('error', function (e) {
			console.log('fail', e.detail);
		});
	} else {
		var btn2 = document.getElementById('btnTest2');
		btn2.style.display = 'block';
		btn2.onclick = function () {
			location.href = 'weixin://dl/business/?t=NUhFcfSZuhv';
		};
	}
	if (data.new === 'true') {
		console.log(auto, 'auto********');
		ULink({
			id: data.linkid || 'usr1cbtpat4292hc',
			data: data,
			selector: '#btnTest1',
			timeout: tm,
			useOpenInBrowerTips: tipitem || 'default',
			lazy: lazy,
			auto: auto,
			useClipboard: clp,
			proxyOpenDownload: proxyOpenDownloadfn,
			onready: function (ctx) {
				console.log('ready', ctx);
				document.getElementById('J_solutionBox').innerText = JSON.stringify(
					ctx.solution,
					null,
					2,
				);
			},
		});
	} else {
		setTimeout(function () {
			ULink.tracker.setMetaInfo({
				oid: 'umtestid_' + oid,
				nickname: '昵称',
				avator: '头像',
				trackurl: location.href,
			});
			ULink.tracker.enter({ page_name: document.title, page: location.href }, function () {
				ULink.tracker.getNextTrackCode(function (data) {
					document.getElementById('ntc').innerText = data;
					console.log('新的追踪码:', data);
				});
				ULink.start({
					id: data.linkid || 'usr1cbtpat4292hc',
					data: data,
					useClipboard: clp,
					useOpenInBrowerTips: tipitem || 'default',
				}).ready(function (ctx) {
					console.log('ready', ctx);
					var option = {
						action: 'click',
						proxyOpenDownload: proxyOpenDownloadfn,
						timeout: tm,
					};
					if (auto) {
						console.log('auto---------', auto);
						ctx.wakeup(Object.assign({}, option, { action: 'load' }));
					}
					document.getElementById('btnTest1').onclick = function (e) {
						ctx.wakeup(option);
					};
					document.getElementById('J_solutionBox').innerText = JSON.stringify(
						ctx.solution,
						null,
						2,
					);
				});
			});
		}, 500);
	}
</script>